package com.android.goal;

import java.util.ArrayList;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class MatchAdapter extends ArrayAdapter<Match>{
	ArrayList<Match> listMatch;	
	int resource;
	Context context;
	
	public MatchAdapter(Context context, int textViewResourceId, 
			ArrayList<Match> objects){		
		super(context, textViewResourceId, objects);
		this.context = context;
//		this.resource = resource;
		this.listMatch = objects;
	}
	
	public View getView(int position, View convertView, ViewGroup parent){
		View matchView = convertView;
		if(matchView == null){
			matchView = new MatchViewGroup(getContext());
		}
		
		final Match match = listMatch.get(position);
		if(match!=null){			
			TextView homeName = ((MatchViewGroup) matchView).homeName;
			TextView awayName = ((MatchViewGroup) matchView).awayName;
			TextView score = ((MatchViewGroup) matchView).score;
			
			homeName.setText(match.getHomeName());
			awayName.setText(match.getAwayName());
			score.setText(match.getScore());
		}
		return matchView;
	}
}
